<!-- 编辑弹窗 -->
<template>
  <el-dialog
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :destroy-on-close="true"
    :lock-scroll="false"
    :title="mType ? '统计API错误' : '账户API错误'"
    :visible="visible"
    custom-class="ele-dialog-form"
    width="500px"
    @update:visible="updateVisible"
  >
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="推广账户:" style="margin-bottom: 6px">
        {{ form.username }}
      </el-form-item>
      <el-form-item label="错误代码:" style="margin-bottom: 6px">
        {{ mType ? form.countMessage.code : form.userMessage.code }}
      </el-form-item>
      <el-form-item label="错误消息:" style="margin-bottom: 6px">
        {{ mType ? form.countMessage.message : form.userMessage.message }}
      </el-form-item>
      <el-form-item label="错误说明:">
        <el-link
          v-if="!mType"
          :underline="false"
          href="https://dev2.baidu.com/content?sceneType=0&pageId=100206&nodeId=166&subhead="
          target="_blank"
          type="primary"
        >
          https://dev2.baidu.com/content?sceneType=0&pageId=100206&nodeId=166&subhead=
        </el-link>
        <el-link
          v-if="mType"
          :underline="false"
          href="https://tongji.baidu.com/api/manual/Chapter3/drapi.html"
          target="_blank"
          type="primary"
        >
          https://tongji.baidu.com/api/manual/Chapter3/drapi.html
        </el-link>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" @click="updateVisible(false)">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "feedAccountMessage",
  props: {
    // 弹窗是否打开
    visible: Boolean,
    // 修改回显的数据
    data: Object,
    // 修改消息类别
    message: Boolean,
  },
  data() {
    return {
      // 点击类别
      mType: this.message,
      // 表单数据
      form: Object.assign(
        {
          userMessage: {
            code: 0,
            message: "",
          },
          countMessage: {
            code: 0,
            message: "",
          },
        },
        this.data
      ),
      // 提交状态
      loading: false,
    };
  },
  watch: {
    data() {
      this.mType = this.message;
      this.form = Object.assign(
        {
          userMessage: {
            code: 0,
            message: "",
          },
          countMessage: {
            code: 0,
            message: "",
          },
        },
        this.data
      );
    },
    message() {
      this.mType = this.message;
    },
  },
  methods: {
    updateVisible(value) {
      this.$emit("update:visible", value);
    },
  },
};
</script>

<style scoped>
</style>
